package room;

import javax.swing.DefaultListModel;

@SuppressWarnings("serial")
public class RoomListModel extends DefaultListModel<Room> {

	
	public Room getRoomByName(String room){
		
		for(int i = 0; i < this.getSize(); i++){
			Room r = this.get(i);
			if(r.roomName.equals(room))
				return r;
		}
		
		return null;
	}
	
	public int getRoomPosition(Room room){
		for(int i = 0; i < this.getSize(); i++){
			Room r = this.get(i);
			if(r.roomName.equals(room.roomName))
				return i;
		}
		
		return -1;
	}
	
	public void update(){
		this.fireContentsChanged(this, 0, this.size());
	}
}
